import env from '../../env.js';
import { dialog } from '../antd-dialog/index.js';

export async function encryptRoute() {
  return await new Promise((resolve, reject) => {
    if (env.DEV) {
      if (window.sessionStorage.getItem('encryptRouteConfirmed') === '1') {
        return resolve(true);
      }
    }
    dialog({
      content: () => import('./form.vue'),
      dialogProps: {
        title: '请输入密码',
        onOk: () => {
          if (env.DEV) {
            window.sessionStorage.setItem('encryptRouteConfirmed', '1');
          }
          resolve(true);
        },
        onCancel: () => reject(),
      },
    });
  });
}
